<template>
  <div>
    <div class="header">
      <img @click="bac()" :src="'./static/lyl/back.png'" alt="">
      <span>我的粉丝</span>
    </div>
    <ul class="da_ul">
      <li v-for="(item,index) in expData" :key="index">
        <img :src="item.avatar" alt="">
        <div class="e_center">
          <p>{{item.user_login}}</p>
          <p>领域：{{item.territory}}</p>
          <p>{{item.signature}}</p>
        </div>
        <span @click="follow(item)">{{item.status?'已关注':'+关注'}}</span>
      </li>
    </ul>

    <transition name="van-slide-right">
      <div v-show="visible" class="tran_right">{{Fade}}</div>
    </transition>
  </div>
</template>

<script>
  import * as search from "../../../api/search.js"
  export default {
    name: "Fensi",
    data(){
      return {
        Fade:'',
        visible:false,
        expData:[]
      }
    },
    mounted(){
      //我的粉丝
      let parms2 = {user_id:this.$store.state.user_id};
      search.userFans(parms2).then(res=>{
        console.log('我的粉丝',res)
        this.expData = res.data;
      })
    },
    methods:{
      bac(){
        history.go(-1)
      },
      follow(item){
        if (item.status==0){
          item.status = 1;
          let flow = {follow_id:item.id,user_id:this.$store.state.user_id,status:1};
          search.follow(flow).then(res=>{
            console.log(res);
            this.visible = true;
            this.Fade = res.msg;
            setTimeout(() => {
              this.visible = false;
            }, 500);
          });
          search.followed(flow).then(res=>{
            console.log(res);
          })
        } else{
          item.status = 0;
          let flow = {follow_id:item.id,user_id:this.$store.state.user_id,status:0};
          search.follow(flow).then(res=>{
            console.log(res);
            this.visible = true;
            this.Fade = res.msg;
            setTimeout(() => {
              this.visible = false;
            }, 500);
          });
          search.followed(flow).then(res=>{
            console.log(res);
          })
        }
      },
    }
  }
</script>

<style scoped>
  .header{
    border-bottom: 2px solid #dcdcdc;
    padding: 20px 40px;
  }
  .header img{
    width: 22px;
    margin-right: 30px;
  }
  .header span{
    font-size: 36px;
    vertical-align: bottom;
  }

  .da_ul li{
    display: flex;
    justify-content: space-between;
    padding: 20px 40px;
    border-bottom: 2px solid #dcdcdc;
  }
  .da_ul li:last-child{
    border-bottom: none;
  }
  .da_ul li img{
    width: 130px;
    height: 130px;
    border-radius: 50%;
  }
  .da_ul li .e_center{
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    width: 55%;
  }
  .da_ul li .e_center p{
    font-size: 32px;
  }
  .da_ul li .e_center p:nth-child(2){
    font-size: 24px;
  }
  .da_ul li>span{
    width: 120px;
    height: 50px;
    line-height: 50px;
    text-align: center;
    border-radius: 10px;
    border: 2px solid #884ca4;
    color: #884ca4;
    font-size: 24px;
  }
</style>
